# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=prrte
pkgver=3.0.0
pkgrel=1
pkgdesc="PMIx Reference RunTime Environment"
arch=(x86_64)
url="https://github.com/openpmix/prrte"
license=(BSD)
depends=(glibc hwloc libevent openpmix)
makedepends=(perl)
provides=(libprrte.so)
source=($pkgname-$pkgver.tar.gz::https://github.com/openpmix/$pkgname/releases/download/v$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('3400f666092531f0f55054fefe0f28aaa94b177f170ad038f3f87a9c62b1fe4139fdde480030afb7eb0147b4775fdd83742424ccb4306234343e244f089935d6')
b2sums=('d4899e08c5ee2766d61fa56d53cd9ecdc9e3c16cb9328476c1d18e7bb65058b57a9d243f5540e15057b1fb6fb4c5d097c869c778a69f525441b6b63778a17038')

prepare() {
  cd $pkgname-$pkgver
  ./autogen.pl
}

build() {
  cd $pkgname-$pkgver
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc/$pkgname
  # prevent excessive overlinking due to libtool
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make V=1
}

check() {
  make -k check -C $pkgname-$pkgver
}

package() {
  depends+=(libpmix.so)

  make DESTDIR="$pkgdir" install -C $pkgname-$pkgver
  install -vDm 644 $pkgname-$pkgver/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
